package homework12月8号.homework1.h4;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/*public class Dog {
    // 叫声
    public void cell(){
        System.out.println("汪汪汪...");
    }
    // 睡觉
    public void sleep(){
        System.out.println("主人  我去睡了哟...");
    }
*/
public class Demo1 {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("czxy.homework.h4.Dog");
        Method cell = aClass.getDeclaredMethod("cell");
        Constructor<?> constructor = aClass.getConstructor();
        Object o = constructor.newInstance();
        cell.invoke(o);

        Method sleep = aClass.getDeclaredMethod("sleep");
        Object o1 = constructor.newInstance();
        sleep.invoke(o1);
    }
}
